import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BizStationMaintenanceVo } from './types';

/**
 * 维保记录-分页查询
 * @param query
 * @returns {*}
 */

export const listMaintenance = (query?: PageQuery): AxiosPromise<BizStationMaintenanceVo[]> => {
  return request({
    url: '/biz-station/station/maintenance/list',
    method: 'get',
    params: query
  });
};

/**
 * 维保记录-详细
 * @param id
 */
export const getMaintenance = (id: string | number): AxiosPromise<BizStationMaintenanceVo> => {
  return request({
    url: '/biz-station/station/maintenance/' + id,
    method: 'get'
  });
};

/**
 * 维保记录-新增
 * @param data
 */
export const addMaintenance = (data: BizStationMaintenanceVo) => {
  return request({
    url: '/biz-station/station/maintenance',
    method: 'post',
    data: data
  });
};

/**
 * 维保记录-修改
 * @param data
 */
export const updateMaintenance = (data: BizStationMaintenanceVo) => {
  return request({
    url: '/biz-station/station/maintenance',
    method: 'put',
    data: data
  });
};

/**
 * 维保记录-删除
 * @param id
 */
export const delMaintenance = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/maintenance/' + id,
    method: 'delete'
  });
};

/**
 * 维保记录-导出
 * @param data
 */
export const exportMaintenance = (data: BizStationMaintenanceVo) => {
  return request({
    url: '/biz-station/station/maintenance/export',
    method: 'post',
    data: data
  });
};

/**
 * 开始维保记录
 * @param data
 */
export const start = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/maintenance/start/' + id,
    method: 'put'
  });
};

/**
 * 结束维保记录
 * @param id
 * @returns
 */
export const finish = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/maintenance/finish/' + id,
    method: 'put'
  });
};
